/*
https://www.luogu.com.cn/problem/P1036
解法2：直接枚举组合。一共枚举k 个数，每次从上一个数字的下一个数字枚举。

https://cdn.class.luogu.com.cn/lils/yugu22jcc3/5.svg
*/
#include <bits/stdc++.h>
using namespace std;

int n, k, x[25], a[25], ans;

void check(int p) {
    for (int x = 2; x * x <= p; x++)
        if (p % x == 0)
            return;
    ans++;
}

void dfs(int pos) {
    if (pos == k + 1) {
        int sum = 0;
        for (int i = 1; i <= k; i++) {
            sum += x[a[i]];
        }

        check(sum);
        return;
    }

    for (int i = a[pos - 1] + 1; i <= n; i++) {
        a[pos] = i;
        dfs(pos + 1);
    }
}

int main(void) {
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
        cin >> x[i];

    dfs(1);

    cout << ans << endl;

    return 0;
}

/* 
g++ dfs/dfs_6.cpp && echo "4 3 3 7 12 19" | ./a.out
g++ dfs/dfs_6.cpp && echo "6 3 3 5 6 7 12 19" | ./a.out
*/

// 写一个二分查找的函数
/*
int binary_search(int x) {
    int l = 1, r = n;
    while (l < r) {
        int mid = (l + r) / 2;
        if (x > x[mid])
        
